import {reqGetUserAddressList, reqGetOrderInfo} from "@/api";
//Home模块
const state = {
    addressList: [],
    orderInfo: {}
}

const actions = {
    async getUserAddressList({commit}) {
        let result = await reqGetUserAddressList()
        if (result.code === 200) {
            commit('GETUSERADDRESSLIST', result.data)
        }
    },
    async getOrderInfo({commit}) {
        let result = await reqGetOrderInfo()
        if (result.code === 200) {
            commit('GETORDERINFO', result.data)
        }
    }
}

const mutations = {
    GETUSERADDRESSLIST(state, addressList) {
        state.addressList = addressList
    },
    GETORDERINFO(state, orderInfo) {
        state.orderInfo = orderInfo
    },
}

const getters = {
    detailArrayList(state) {
        return state.orderInfo.detailArrayList || []
    }

}//为了简化仓库中的数据

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}

